package com.panshi.interceptor;

import com.panshi.interceptor.LogicInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class LogicConfiguration implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器
        LogicInterceptor logicInterceptor = new LogicInterceptor();
        InterceptorRegistration registration = registry.addInterceptor(logicInterceptor);

        //拦截路径
        //registration.addPathPatterns("/**");
        registration.addPathPatterns("/addlike");//需要拦截
        registration.addPathPatterns("/addCollect");//需要拦截
        registration.addPathPatterns("/addDiscuss");//需要拦截
        //排除路径
        registration.excludePathPatterns("/**");
        /*registration.excludePathPatterns("/intercept/inter");//重定向的路径
        registration.excludePathPatterns("/logic");//登录页面
        registration.excludePathPatterns("/register");//注册页面
        registration.excludePathPatterns("/reg/register");//注册
        registration.excludePathPatterns("/user/identify");//校验图形验证码
        registration.excludePathPatterns("/send/send");//发送邮件
        registration.excludePathPatterns("/reg/sendIdentify");//校验邮箱验证码
        registration.excludePathPatterns("/verifyCode/verify");//图形验证码
        registration.excludePathPatterns("/user/identifyErrors");//登录失败5次
        registration.excludePathPatterns("/user/logic");//登录
        registration.excludePathPatterns("/information");//资讯页面
        registration.excludePathPatterns("/category/{category}");//分类
        registration.excludePathPatterns("/detail/{number}");//文章详情页
        registration.excludePathPatterns("/type");
        registration.excludePathPatterns("/load");//加载更多
        registration.excludePathPatterns("/category/{type}/{category}");
        registration.excludePathPatterns("/category/{type}/{category}/{currentPage}");*/
        /*registration.excludePathPatterns("/message");
        registration.excludePathPatterns("/findDiscussByFid");*/


        //排除资源请求
        registration.excludePathPatterns("/static/**");
        registration.excludePathPatterns("/static/**/*.js");
        registration.excludePathPatterns("/static/**/*.css");
        registration.excludePathPatterns("/static/image/*.jpg");
        registration.excludePathPatterns("/static/image/*.png");


    }
}
